# !/usr/bin/env python
# -*-coding:utf-8 -*-

"""
# File       : Jenkins.py
# Time       ：2023/12/17 17:34
# Author     ：Y-aong
# version    ：python 3.10
# Description：jenkins操作
"""
from pydantic import Field

from conf.config import OrderLinesConfig
from orderlines.libraries.BaseTask import BaseTask
from orderlines.utils.base_orderlines_type import BasePluginParam


class StartJenkinsParam(BasePluginParam):
    jenkins_name: str = Field(description='jenkins名称')


class StopJenkinsParam(BasePluginParam):
    jenkins_queue_id: int = Field(description='jenkins队列id')


class JenkinsStatusParam(BasePluginParam):
    jenkins_queue_id: int = Field(description='jenkins队列id')


class JenkinsLogParam(BasePluginParam):
    jenkins_name: str = Field(description='jenkins名称')
    jenkins_queue_id: int = Field(description='jenkins队列id')


class Jenkins(BaseTask):
    version = OrderLinesConfig.version
    title = 'jenkins操作'
    category = 'devops'

    def __init__(self):
        super(Jenkins, self).__init__()

    def start_jenkins(self, param: StartJenkinsParam):
        """jenkins启动"""
        return {'status': self.success}

    def get_jenkins_status(self, param: JenkinsStatusParam):
        """jenkins状态"""
        return {'status': self.success}

    def get_jenkins_log(self, param: JenkinsLogParam):
        """jenkins日志"""
        return {'status': self.success}

    def stop_jenkins(self, param: StopJenkinsParam):
        """jenkins停止"""
        return {'status': self.success}
